<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>简易计算器</title>
	</head>
	<body>
		<table>
			<tr>
				<td>第一个数：</td>
				<td colspan="4"><input type="text" id="text1"/></td>
				
			</tr>
			<tr>
				<td>第二个数：</td>
				<td colspan="4"><input type="text" id="text2" /></td>
			</tr>
			<tr>
				<td></td>
				<td><button id="bt1" onclick="jia()" onfocusout="">+</button></td>
				<td><button id="bt2" onclick="jian()">-</button></td>
				<td><button id="bt3" onclick="cheng()">*</button></td>
				<td><button id="bt4" onclick="chu()">/</button></td>
			</tr>
			<tr>
				<td>计算结果：</td>
				<td colspan="4"><input type="text" name="" id="resullt" value="" /></td>
			</tr>
		</table>
		<script>
		
		var result;
		var jia=function(){
			var text1=document.getElementById("text1").value;
			var text2=document.getElementById("text2").value;
			if(text1==""||text2==""){
				alert("数值存在空值");
				return false;
			}
			var num1=Number(text1);
			var num2=Number(text2);
			result= (num1*1000+num2*1000)/1000;
			document.getElementById("resullt").value=result;
		}
		var jian=function(){
		var text1=document.getElementById("text1").value;
		var text2=document.getElementById("text2").value;
		if(text1==""||text2==""){
			alert("数值存在空值");
			return false;
		}
		var num1=Number(text1);
		var num2=Number(text2);
		result= num1-num2;
		document.getElementById("resullt").value=result;
		}
		var cheng=function(){
			var text1=document.getElementById("text1").value;
			var text2=document.getElementById("text2").value;
			if(text1==""||text2==""){
				alert("数值存在空值");
				return false;
			}
			var num1=Number(text1);
			var num2=Number(text2);
			result= num1*num2;
			document.getElementById("resullt").value=result;
		}
		var chu=function(){
			var text1=document.getElementById("text1").value;
			var text2=document.getElementById("text2").value;
			if(text1==""||text2==""){
				alert("数值存在空值");
				return false;
			}
			var num1=Number(text1);
			var num2=Number(text2);
			if(num2==0){
				alert("除数不能为0！！");
				return false;
			}
			result= num1/num2;
			document.getElementById("resullt").value=result;
		}
	
		</script>
	</body>
</html>
